﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Refugees.Views.Windows
{
    /// <summary>
    /// Логика взаимодействия для Uslugi.xaml
    /// </summary>
    public partial class Uslugi : Window
    {
        Models.Recuest recuest = new Models.Recuest();
        Repositories.TypeOfHelpRepository typeOfHelpRepository = new Repositories.TypeOfHelpRepository();
        Repositories.RecuestRepository recuestRepository = new Repositories.RecuestRepository();
        public Uslugi()
        {
            if (Repositories.ModelRepository.PersonalData == null)
            {
                MessageBox.Show("Сначала необходимо выбрать данные для услуги");
                new Personals().Show();
                Close();
            }
            recuest.PersonalData = Repositories.ModelRepository.PersonalData;
            InitializeComponent();
            recuestRepository.AddRecuest(recuest);
            recuest.TypeOfHelp = typeOfHelpRepository.GetTypeOfHelp("Медицинская помощь");
            LabelHelp.Content = recuest.TypeOfHelp.Name;
            this.DataContext = recuest;
        }

        private void UserClick(object sender, RoutedEventArgs e)
        {
            new Personals().Show();
            Close();
        }

        private void UsliguClick(object sender, RoutedEventArgs e)
        {
            new Uslugies().Show();
            Close();
        }

        private void ContactsClick(object sender, RoutedEventArgs e)
        {
            new ContactNumbers().Show();
            Close();
        }

        private void NewsClick(object sender, RoutedEventArgs e)
        {
            new News().Show();
            Close();
        }

        private void Submit(object sender, RoutedEventArgs e)
        {
            if (Repositories.ModelRepository.Save())
            {
                MessageBox.Show("Данные сохранены успешно");
                new Uslugies().Show();
                Close();
            }
            else
            {
                MessageBox.Show("Данные не сохранены. Повторите попытку позже или проверьте данные");
            }
        }

        private void MedClick(object sender, RoutedEventArgs e)
        {
            recuest.TypeOfHelp = typeOfHelpRepository.GetTypeOfHelp("Медицинская помощь");
            LabelHelp.Content = recuest.TypeOfHelp.Name;
        }

        private void GumClick(object sender, RoutedEventArgs e)
        {
            recuest.TypeOfHelp = typeOfHelpRepository.GetTypeOfHelp("Гуманитарная помощь");
            LabelHelp.Content = recuest.TypeOfHelp.Name;
        }

        private void UriClick(object sender, RoutedEventArgs e)
        {
            recuest.TypeOfHelp = typeOfHelpRepository.GetTypeOfHelp("Юридическая помощь");
            LabelHelp.Content = recuest.TypeOfHelp.Name;
        }

        private void PsycoClick(object sender, RoutedEventArgs e)
        {
            recuest.TypeOfHelp = typeOfHelpRepository.GetTypeOfHelp("Психологическая помощь");
            LabelHelp.Content = recuest.TypeOfHelp.Name;
        }
    }
}
